package com.maple.common.widget.view

import android.content.Context
import android.graphics.drawable.Drawable
import android.graphics.drawable.GradientDrawable
import android.util.AttributeSet
import android.view.View
import android.widget.LinearLayout
import com.maple.common.R
import com.maple.utils.ext.layoutInflater
import com.maple.utils.util.UIUtils

class LineView: LinearLayout {

    constructor(context: Context) : this(context, null)

    constructor(context: Context, attributeSet: AttributeSet?) : this(context, attributeSet, 0)

    constructor(context: Context, attributeSet: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attributeSet,
        defStyleAttr
    ) {
        initView(
            context,
            attributeSet,
            defStyleAttr
        )
    }

    private var vLine: LinearLayout? = null
    private fun initView(context: Context, attributeSet: AttributeSet?, defStyleAttr: Int = 0) {
        val view: View = context.layoutInflater.inflate(R.layout.layout_line_view, this)
        vLine = view.findViewById(R.id.v_line)
    }


    fun setShapeDrawable(resId: Int) {
        vLine?.let {
            it.background = UIUtils.getDrawable(resId)
        }
    }

}